package com.glsc.ngateway.common.api.oaflow.feign;

import com.glsc.ngateway.common.api.common.config.FeignMultipartSupportConfig;
import com.glsc.ngateway.common.api.common.dto.PageDto;
import com.glsc.ngateway.common.api.common.dto.PageQueryParamDto;
import com.glsc.ngateway.common.api.oaflow.dto.*;
import com.glsc.ngateway.common.api.oaflow.dto.oaflow.SystemFlowStatisticsDto;
import com.glsc.ngateway.common.api.oaflow.dto.oaflow.WorkflowBaseDto;
import com.glsc.ngateway.common.api.oaflow.dto.oaflow.WorkflowBaseQueryParamDto;
import com.glsc.ngateway.common.api.oaflow.dto.oaflow.WorkflowRequestbaseDto;
import com.glsc.ngateway.common.api.oaflow.dto.oaform.FormDictInfoDto;
import com.glsc.ngateway.common.api.oaflow.dto.oaform.FormInfoDto;
import com.glsc.ngateway.common.api.oaflow.dto.param.ParamFlowSearchDto;
import com.glsc.ngateway.common.api.oaflow.dto.param.ParamOaLoginDto;
import com.glsc.ngateway.common.api.oaflow.dto.xirtrade.TOaFlowXirTradeBaseInfoDto;
import com.glsc.ngateway.common.api.oaflow.dto.xirtrade.TOaFlowXirTradeInfoDeleteParamDto;
import com.glsc.ngateway.common.api.oaflow.dto.xirtrade.TOaFlowXirTradeInfoSearchParamDto;
import com.glsc.ngateway.common.api.oaflow.resp.CommonResponse;
import com.glsc.ngateway.common.api.oaflow.resp.OaflowResponse;
import com.glsc.ngateway.common.api.oaflow.resp.ResponseLoginDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@FeignClient(value = "eureka-client-oaflow", configuration = FeignMultipartSupportConfig.class) // 调用的服务的名称
public interface IFeignOaFlowService {
    /**
     * 调用网关创建OA流程
     *
     * @param dataMap
     * @param flowId
     * @return
     */

    @RequestMapping(value = "/createOaflow")
    String createOaFlow(@RequestBody Map<String, Object> dataMap, @RequestParam("flowId") String flowId,
                        @RequestParam(value = "isnextflow", defaultValue = "0", required = false) String isnextflow,
                        @RequestParam(value = "subscribe", required = false) boolean subscribe);

    @RequestMapping(value = "/createOaflow", method = RequestMethod.POST)
    String createOaFlow(@RequestBody Map<String, Object> dataMap, @RequestParam("flowId") String flowId);

    @RequestMapping(value = "/createOaflowWithDeptId", method = RequestMethod.POST)
    String createOaflowWithDeptId(@RequestBody Map<String, Object> dataMap, @RequestParam("flowId") String flowId);

    @RequestMapping(value = "/createOaflow", method = RequestMethod.POST)
    String createOaFlow(@RequestBody DigitalKeyCreateOaFlowDto dataMap, @RequestParam("flowId") String flowId);

    @RequestMapping(value = "endOaFlow")
    String endOaFlow(@RequestParam("requestId") String requestId);

    @RequestMapping(method = RequestMethod.POST, value = "oaLogin")
    CommonResponse<ResponseLoginDto> oaLogin(@RequestBody ParamOaLoginDto params);

    @RequestMapping(value = "/syncflow/syncFlow2Oa", method = RequestMethod.POST)
    OaflowResponse<Void> syncFlow2Oa(@RequestBody SyncPlatformFlowCommonDto<?> param);

    @RequestMapping(value = "/syncflow/endOaFlow", method = RequestMethod.POST)
    OaflowResponse<String> endOaFlow(@RequestParam("workflowId") String workflowId, @RequestParam("taskId") String taskId);

    @RequestMapping(value = "/getSystemOaFlowList", method = RequestMethod.POST)
    OaflowResponse<List<VITSystemOAFlowResourceDto>> getSystemOaFlowList(@RequestBody ParamFlowSearchDto params);

    @RequestMapping(value = "/getOAFlowStatistics", method = RequestMethod.POST)
    OaflowResponse<SystemFlowStatisticsDto> getOAFlowStatistics(@RequestBody SystemFlowStatisticsSearchParamDto params);

    /**
     * 调用网关批量上传接口
     *
     * @param file
     * @return
     */
    @RequestMapping(value = "/uploadDoc", method = RequestMethod.POST, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadDoc(@RequestPart(value = "file") MultipartFile[] file);

    /**
     * 查询流程表单数据
     *
     * @param requestId
     * @return
     */
    @RequestMapping(value = "/getRequestData", method = RequestMethod.POST)
    String getRequestData(@RequestParam("requestId") String requestId);

    @RequestMapping(value = "/getRequestDataOrigin", method = RequestMethod.POST)
    String getRequestDataOrigin(@RequestParam("requestId") String requestId,@RequestParam("workflowId") String workflowId);

    @RequestMapping(value = "/xy/callXy", method = RequestMethod.POST)
    String callXy(@RequestBody String param);

    @RequestMapping(value = "getRequestBase")
    CommonResponse<List<WorkflowRequestbaseDto>> getRequestDataNew(@RequestBody List<String> requestId);

    /**
     * 从网关下载OA流程附件
     *
     * @param fileid
     * @return
     */
    @RequestMapping(value = "/downloadSingleAppendix", method = RequestMethod.POST)
    ResponseEntity<byte[]> downloadSingleAppendix(@RequestParam("fileid") String fileid);

    /**
     * 从网关获取OA流程PDF
     *
     * @param srcPath
     * @param sessionId
     * @return
     */
    @RequestMapping(value = "/htmlToPdf", method = RequestMethod.POST)
    ResponseEntity<byte[]> getOaFlowPdf(@RequestParam("srcPath") String srcPath, @RequestParam("sessionId") String sessionId);

    @RequestMapping(value = "/getWorkflowBase", method = RequestMethod.GET)
    String getWorkflowBaseByName(@RequestParam("workflowName") String workflowName);

    @RequestMapping(value = "/addDigitalCertificate", method = RequestMethod.POST)
    String addDigitalCertificate(@RequestBody UFyyglzbszzszbDto uFyyglzbszzszbDto);

    @RequestMapping(value = "/getWorkflowRequestBase", method = RequestMethod.GET)
    String getWorkflowRequestBase(@RequestParam("beginDate") String beginDate, @RequestParam("endDate") String endDate, @RequestParam("workflowId") String workflowId);

//    /**
//     * 从网关获取OA流程图
//     * @param oaWorkflowPicDto   OA登录
//     * @param requestid          OA流程实例ID
//     * @return
//     */
//    @RequestMapping(value = "/getOaWorkflowPic",method = RequestMethod.POST)
//    String getOaWorkflowPic(@RequestBody OaWorkflowPicReqDto oaWorkflowPicDto, @RequestParam("requestid")String requestid, @RequestParam("wfid")String wfid);
//
//    @RequestMapping(value = "/getWorkFlowOaPicData",method = RequestMethod.GET)
//    FlowDetailFrontDto getWorkFlowOaPicData(@RequestParam("requestId")String requestId);

    @RequestMapping(method = RequestMethod.GET, value = "/getRequestLogList")
    CommonResponse<OaRequestLogResp> getRequestLogList(@RequestParam("requestId") Integer requestId,
                                                       @RequestParam(value = "account", required = false) List<String> roleList);

    @GetMapping("/dolphinScheduler/checkSysnLog")
    OaflowResponse<Void> checkSysnLog();

    @GetMapping("/dolphinScheduler/syncXirTrade")
    OaflowResponse<Void> syncXirTrade(@RequestParam(value = "date", required = false) String date,
                                      @RequestParam(value = "unPushFlow", required = false) boolean unPushFlow);

    /**
     * 衡泰指令同步记录功能
     */
    @PostMapping("/oaflow/xir/search")
    @ApiOperation(value = "查询同步记录", notes = "查询同步记录")
    OaflowResponse<PageDto<TOaFlowXirTradeBaseInfoDto>> query(@RequestBody PageQueryParamDto<TOaFlowXirTradeInfoSearchParamDto> queryParam);

    @PostMapping("/oaflow/xir/delete")
    @ApiOperation(value = "删除记录", notes = "删除记录")
    OaflowResponse<Void> delete(@RequestBody TOaFlowXirTradeInfoDeleteParamDto param);

    @RequestMapping(value = "pageWorkflowBase", produces = {"application/json"})
    CommonResponse<PageDto<WorkflowBaseDto>> pageWorkflowBase(@RequestBody PageQueryParamDto<WorkflowBaseQueryParamDto> param);

    @RequestMapping(value = "/getWorkFlowOaFormInfo", method = RequestMethod.GET)
    CommonResponse<List<FormInfoDto>> getWorkFlowOaFormInfo(@RequestParam("workflowId") String workflowId);

    @RequestMapping(value = "/getWorkFlowOaFormDictInfo", method = RequestMethod.GET)
    CommonResponse<List<FormDictInfoDto>> getWorkFlowOaFormDictInfo(@RequestParam("workflowId") String workflowId);


    /**
     * 从网关下载OA流程附件
     * @param fileid
     * @return
     */
    @RequestMapping(value = "/downloadSingleAppendixNew",method = RequestMethod.POST)
    ResponseEntity<byte[]> downSingleAppendixFromOANew(@RequestParam("fileid") String fileid);

}
